package org.cheetah.youbet;

import org.cheetah.youbet.core.Xls;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ResourceBundle;
import org.apache.poi.POIXMLFactory;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.tika.parser.microsoft.ooxml.POIXMLTextExtractorDecorator;

/**
 * Hello world!
 *
 */
@Deprecated
public class CreateBet 
{
    
    public static ThreadLocal<byte[]> xls = new ThreadLocal<byte[]>();
    
    static final ResourceBundle rb = ResourceBundle.getBundle("org.cheetah.youbet.etc.youbet");

    
    private static String url = rb.getString("url.http.palinsesto.sisal");
//    private static String url = "file:///Users/edoardo/Palinsesto calcio.xls";
//    private static String url = "file:///Users/edoardo/Downloads/Palinsesto calcio.xls";
    public static void main( String[] args ) throws MalformedURLException, IOException, InvalidFormatException
    {
//        
        URL _url = new URL(url);
        URLConnection con = _url.openConnection();
        InputStream in =con.getInputStream();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        int ch = 0;
        byte[] buffer = new byte[1024];
        while((ch=in.read(buffer))>0){
            out.write(buffer, 0, ch);
        }
        in.close();
        out.flush();
        out.close();
        CreateBet.xls.set(out.toByteArray());
        
        Xls xls = Xls.getInstance(out.toByteArray());
        
        xls.write();
        
        
        
    }
}
